<!doctype html>
<html class="no-js fixed-layout">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>首页</title>
  <meta name="description" content="index">
  <meta name="keywords" content="index">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="/static/assets/i/favicon.png">
  <link rel="apple-touch-icon-precomposed" href="/static/assets/i/app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="/static/assets/css/amazeui.min.css"/>
  <link rel="stylesheet" href="/static/assets/css/admin.css">
  <style type="text/css">
    .input_width{
      width: 200px;
    }
  </style>
</head>
<body>



  <div class="admin-content">
    <div class="admin-content-body">

      <div class="am-g">


 
        <div class="am-u-sm-12 am-u-md-12 ">
          <!--中间侧块 注意下面是form表-->
          
          <div class="am-form-group">

            <div class="am-g am-margin-top am-form-group">
              <div class="am-u-sm-5 am-u-md-6 am-text-right">责任单位：</div>
              <div class="am-u-sm-7 am-u-md-4 am-u-end" style="padding-left: 0px;">

                <select  id='organize_id' name='organize_id' class="input_width" required="" onchange="change()"> 
                  {% for i in deptinfo %}
                  {% if i.organize_id == taskinfo.0.charge_dept %}
                  <option value={{ i.organize_id }} selected="selected">{{ i.name }}</option> 
                  {% else %}
                  <option value={{ i.organize_id }} >{{ i.name }}</option>
                  {% endif %}
                  {% endfor %}
                </select>
              </div>

            </div>
            <hr/>
            <div class="am-g am-margin-top am-form-group" id="bridge_csbm" >
              <div class="am-u-sm-5 am-u-md-6 am-text-right">责任人：</div>
              <div class="am-u-sm-7 am-u-md-4 am-u-end" style="padding-left: 0px;">
                <select  id='user_id' name='user_id' class="input_width" required="">
                  {% for i in userInfo %}
                  {% if i.user_id == taskinfo.0.charge_user %}
                  <option value={{ i.user_id }} selected="selected">{{ i.real_name }}</option> 
                  {% else %}
                  <option value={{ i.user_id }} >{{ i.real_name }}</option>
                  {% endif %}
                  {% endfor %}
                </select>
              </div>

            </div>
            <hr/>

            <div class="am-g am-margin-top am-form-group" id="bridge_csbm" >
              <div class="am-u-sm-5 am-u-md-6 am-text-right">检查时间：</div>
              <div class="am-u-sm-7 am-u-md-4 am-u-end" style="padding-left: 0px;">
                <div>
                  {{ taskinfo.0.task_date|date:"Y-m-d H:i:s" }}
                </div>

              </div>

            </div>
            <hr/>
            <div class="am-g am-margin-top am-form-group" id="bridge_csbm" >
              <div class="am-u-sm-5 am-u-md-6 am-text-right">天气：</div>
              <div class="am-u-sm-7 am-u-md-4 am-u-end" style="padding-left: 0px;">
                <select data-am-selected="{btnSize: 'sm'}" id='txtWeather'>
                  {% if taskinfo.0.weather == "晴" %}
                  <option selected="selected" value="晴" >晴</option>
                  {% else %}
                  <option value="晴">晴</option>
                  {% endif %}
                  {% if taskinfo.0.weather == "多云" %}
                  <option selected="selected" value="多云">多云</option>
                  {% else %}
                  <option value="多云">多云</option>
                  {% endif %}
                  {% if taskinfo.0.weather == "小雨" %}
                  <option selected="selected" value="小雨">小雨</option>
                  {% else %}
                  <option value="小雨">小雨</option>
                  {% endif %}
                  {% if taskinfo.0.weather == "大雨" %}
                  <option selected="selected" value="大雨">大雨</option>
                  {% else %}
                  <option value="大雨">大雨</option>
                  {% endif %}
                  {% if taskinfo.0.weather == "下雪" %}
                  <option selected="selected" value="下雪">下雪</option>
                  {% else %}
                  <option value="下雪">下雪</option>
                  {% endif %}
                  {% if taskinfo.0.weather == "大风" %}
                  <option selected="selected" value="大风">大风</option>
                  {% else %}
                  <option value="大风">大风</option>
                  {% endif %}
                </select>

              </div>

            </div>
            <hr/>
            <div class="am-g am-margin-top am-form-group" id="bridge_csbm" >
              <div class="am-u-sm-5 am-u-md-6 am-text-right">气温：</div>
              <div class="am-u-sm-7 am-u-md-4 am-u-end" style="padding-left: 0px;">
                <input type="text" value="{{ taskinfo.0.temperature }}" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" class="am-input-lg" id='txtTemperature' min='-66' max='66' >℃

              </div>

            </div>
            <hr/>
  
            
          </div>
          
        </div>
        <div class="am-u-sm-12 am-u-md-6">
          <div class="am-btn-toolbar">
            <div class="am-btn-group am-btn-group-xs" style="padding: 0 280px;">

              <button type="button" class="am-btn am-btn-primary am-btn-xs" onclick="modify_submit({{ taskinfo.0.task_id }})">保存</button>


            </div>
          </div>
        </div>

      </div>
    </div>

  </div>



<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/static/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="/static/assets/js/amazeui.min.js"></script>
<script src="/static/assets/js/amazeui.tree.js"></script>
<script src="/static/assets/datatables/amazeui.datatables.min.js"></script>
<script src="/static/assets/dialog/amazeui.dialog.min.js"></script>
<script src="/static/assets/js/amazeui.chosen.min.js"></script>
<script src="/static/assets/js/app.js"></script>
<script type="text/javascript">

$.ajaxSetup({
  data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
});

function modify_submit(task_id){
  // var bridge_id = $("#bridge_id option:selected").val();
  // var bridge_name = $("#bridge_id option:selected").text();
  var organize_id = $("#organize_id option:selected").val();
  var user_id = $("#user_id option:selected").val();
  var txtWeather = $("#txtWeather option:selected").val();
  var txtTemperature = $("#txtTemperature").val();

  // var organize_id = $("#organize_id option:selected").val();
  // var name = $("#organize_id option:selected").text();
  // var checkdate = $("#checkdate").val();

 
  if(txtWeather==''){
    AlertMSG("请选择天气！")
  }else if(txtTemperature==''){
    AlertMSG("请输入温度！")
  }else {
    $.ajax({
      "url":"/QLXJ_XJYW_RCXJ_MODIFYSAVE/",
      "data":{"task_id":task_id,"txtWeather":txtWeather,"txtTemperature":txtTemperature,"charge_dept":organize_id,"charge_user":user_id},
      "datatype":"json",
      "type":"post",
      "async":"false"
      }).success(function(data){
        if (data.status == 1) {
          var index = parent.layer.getFrameIndex(window.name);
          parent.location.reload();
          parent.layer.close(index);


        } else {
          AlertMSG(data.message)
        }
      }).error(function(data){
        AlertMSG("保存失败！")
      });
  }
}

function change(){
  var organize_id = $("#organize_id option:selected").val();

  $.ajax({
      "url":"/QLXJ_XJYW_DQJC_USER/?organize_id="+organize_id+"",
      "datatype":"json",
      "type":"get",
      "async":"false"
      }).success(function(data){
        if (data.status == 1) {
          $("#user_id").empty();
          for(var i=0;i<data.data.length;i++){
            $('#user_id').append('<option value='+data.data[i].user_id+' >'+data.data[i].real_name+'</option>');
          }

    

        } else {
          AlertMSG(data.message)
        }
      }).error(function(data){
        AlertMSG("读取负责人失败！")
      });
}

var AlertMSG=function(msg){
    AMUI.dialog.alert({ title: '错误提示', content: msg, onConfirm: function() { console.log('close'); } });
}
</script>
</body>

</html>